<template>
  <div >
    <table class="mars" cellspacing="1" cellpadding="0" width="100%" border="0">
      <tbody>
        <tr bgcolor="#fba661" height="30">
          <td><div align="center">登录名</div></td>
          <td><div align="center">用户组</div></td>
          <td><div align="center">删除</div></td>
        </tr>

        <tr bgcolor="#e4f1fe" v-for="(user, index) in userList" :key="index">
          <td bgcolor="#f3f3f3">
            <div align="center">{{ user.username }}</div>
          </td>
          <td bgcolor="#f3f3f3">
            <div align="center">{{ user.gname }}</div>
          </td>
          <td bgcolor="#f3f3f3">
            <div align="center">
              <a href="#" @click="deleteUser(user.uid, user.gid)">删除</a>
            </div>
          </td>
        </tr>
        <tr bgcolor="#e4f1fe">
          <td bgcolor="#f3f3f3" colspan="3">
            <div align="center"><a href="/declare/admin/addUser">添加用户</a></div>
          </td>
        </tr>
      </tbody>
    </table>
    <div id="container" >
    <div id="footer">
    <p><a href="http://www.ascenttech.com.cn/" target="_blank">版权所有：北京亚思晟商务科技有限公司 &copy;2004-2008|京ICP备05005681</a></p>
    </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import { getUsers } from "@/api/AdminUser";
export default {
  data: function () {
    return {
      user: {
        uid: "",
        gid: "",
        username: "",
        gname: "",
      },
      userList: "",
    };
  },
    mounted() {
        getUsers().then((resp) => {
         this.userList = resp.data.data;
      console.log(resp.data.data);
    })
  },
  methods: {
    deleteUser: function (uid, gid) {
      axios.post("http://localhost:8080/api/admin/deleteUser", { uid: uid, gid: gid }).then((resp) => {
        console.log(resp.data.code + " " + resp.data.msg);
        location.href = "/declare/admin/userList";
      });
    },
  },
};
</script>

<style>
</style>